package com.qyer.commons.kafka;

/**
 * User: Z J Wu Date: 2016/07/26 Time: 11:08 Package: com.qyer.commons.kafka
 */
public abstract class BasicQueueOperationComponent<CONTENT, R1, R2> {

  protected OperationHook<CONTENT, R1> beforeOperationHook;
  protected OperationHook<CONTENT, R2> afterOperationHook;

  protected R1 beforeOperation(CONTENT content) {
    return ((beforeOperationHook == null) || (content == null)) ? null : beforeOperationHook
      .operate(content);
  }

  protected R2 afterOperation(CONTENT content) {
    return ((afterOperationHook == null) || (content == null)) ? null : afterOperationHook
      .operate(content);
  }

  public void setBeforeOperationHook(OperationHook<CONTENT, R1> beforeOperationHook) {
    this.beforeOperationHook = beforeOperationHook;
  }

  public void setAfterOperationHook(OperationHook<CONTENT, R2> afterOperationHook) {
    this.afterOperationHook = afterOperationHook;
  }
}

